import sys
import os
try:
  import numpy as np
  from PIL import Image
except:
  os.system("pip install numpy pillow")
  import numpy as np
  from PIL import Image

def show(path):
  try:
    img=Image.open(path)
  except:
    return
  var1 = os.get_terminal_size().columns
  w, h = img.size
  img = img.resize((var1, int(var1/w*h)), Image.ANTIALIAS).rotate(90, expand = True).transpose(Image.FLIP_TOP_BOTTOM)
  w, h = img.size
  img = np.array(img)

  for i_2 in range(int(w/var6)):
    var5 = ""
    for i_1 in range(h):
      var5 = ''.join([var5, "\033[1;48;2;", ';'.join(map(str, img[i_1, int(var6*i_2)].tolist())), 'm '])
    print(var5)
  print('\033[1;48;2;0;0;0m > %s' %path, flush=True)

def act_var6(arg):
  global var6
  var6 = float(arg)

def main(args):
  global var6
  var6 = float(2)
  var7 = {"s":act_var6, "size":act_var6,}
  for i in args[1:]:
    if i.startswith('-'):
      var8 = i.strip('-').split('-')
      var9 = var7[var8[0]]
      var9(var8[1])
  for i in args[1:]:
    if os.path.isdir(i):
      for i2 in os.listdir(i):
        show(i+r'/'+i2)
    else:
      show(i)

if __name__ == "__main__":
  try:
    main(sys.argv)
  except:
    print('\033[1;48;2;0;0;0m', flush=True, end='')
    sys.exit(0)
